package net.entelijan.cobean.table;

import java.beans.PropertyChangeEvent;

import net.entelijan.cobean.core.impl.INamedPropertyChangeListener;

public class SortAndNotifyPropertyChangeListener implements
		INamedPropertyChangeListener {

	private String name;

	private StringBuilder sb = new StringBuilder();

	public SortAndNotifyPropertyChangeListener(String name) {
		this.name = name;
	}

	@Override
	public String getName() {
		return this.name;
	}

	@Override
	public void propertyChange(PropertyChangeEvent evt) {
		if (evt.getPropertyName().equals(this.name)) {
			final Object newVal = evt.getNewValue();
			final Object oldVal = evt.getOldValue();
			final String propName = evt.getPropertyName();
			sb.append("[propertyChange propName='" + propName + "' oldVal='"
					+ oldVal + "' newVal='" + newVal + "']");
		}
	}

	public String getInfo() {
		return sb.toString();
	}

}
